package com.example.messagedemo.websocket.cilent;

import com.example.messagedemo.common.CommonSendStatus;
import com.example.messagedemo.model.base.BaseMap;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;

import javax.annotation.Resource;

/**
 * Redis客户端消息
 *
 * @author dlp
 * @date 2024/08/22
 */
@Configuration
public class MessageRedisClient {

    @Resource
    private RedisTemplate<String, Object> redisTemplate;


    /**
     * 发送消息
     *
     * @param handlerName
     * @param params
     */
    public void sendMessage(String handlerName, BaseMap params) {
        params.put(CommonSendStatus.HANDLER_NAME, handlerName);
        redisTemplate.convertAndSend(CommonSendStatus.REDIS_TOPIC_NAME, params);
    }

}
